﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using StaffDotNet.CollapsiblePanel;
namespace QuanLyChungCu_V
{
    public partial class frmMain : Form
    {

        public frmMain()
        {
            DataColumn col = new DataColumn("111");
            DataTable dt = new DataTable();
            dt.Columns.Add(col);
            DataRow row = dt.NewRow();
            row[col] = 123;
            dt.Rows.Add(row);
            BindingSource bds = new BindingSource();
            bds.DataSource = dt;
            InitializeComponent();
            bngMain.BindingSource = bds;
           
        }
        private void Themdan()
        {
        }
        private void Themnhanvien()
        {
        }
        private void Themvipham()
        {
        }
        private void Themdichvu()
        {
        }
        private void Themcanho()
        {
        }
        private void groupBox3_Enter(object sender, EventArgs e)
        {

        }

        private void collapsiblePanel1_Load(object sender, EventArgs e)
        {

        }

        private void cpnManApartment_Load(object sender, EventArgs e)
        {

        }


        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }


        private void cpnManservice_Load(object sender, EventArgs e)
        {

        }


        private void cpnManPeople_Load(object sender, EventArgs e)
        {

        }

      

        private void bngAddNewItem_Click(object sender, EventArgs e)
        {
            
            Themdan();
            {
                BindingSource bds = new BindingSource();
                try
                {
                   // PeopleManagermentService p_man_service = new PeopleManagermentService();
                   // p_man_service.AddPeople(mtxtTenND.Text, "", new DateTime( ));
                    //bds.DataSource = p_man_service.FindPeople("");
                    //dgvMain.DataSource = bds;
                }
                catch (ApplicationException ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                if (cpnManPeople.PanelState == PanelStateOptions.Expanded)
                {

                    dlgAddPeople dlg = new dlgAddPeople();



                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {

                       
                        MessageBox.Show("Thêm thành công", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Chưa có người dân nào được thêm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
            }

            Themnhanvien();
            {
                if (cpnNhanVien.PanelState == PanelStateOptions.Expanded)
                {
                    dlgAddStaff dlg = new dlgAddStaff();
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        MessageBox.Show("Thêm thành công", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Chưa có nhân viên nào được thêm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }


                Themdichvu();
                {
                    if (cpnManservice.PanelState == PanelStateOptions.Expanded)
                    {
                        dlgAddService dlg = new dlgAddService();
                        if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            MessageBox.Show("Thêm thành công", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Chưa có dịch vụ nào được thêm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }


                Themcanho();
                {
                    if (cpnManApartment.PanelState == PanelStateOptions.Expanded)
                    {
                        dlgAddApartment dlg = new dlgAddApartment();
                        if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            MessageBox.Show("Đã thêm căn hộ", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Chưa có căn hộ nào được thêm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }


            Themvipham();
            {
                if (cpnViPham.PanelState == PanelStateOptions.Expanded)
                {
                    dlgThemViPham dlg = new dlgThemViPham();
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        MessageBox.Show("Đã thêm vi phạm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Chưa có vi phạm nào được thêm", "Xong", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }

        private void cpnNhanVien_Load(object sender, EventArgs e)
        {

        }

        private void cpnViPham_Load(object sender, EventArgs e)
        {


        }

        private void btLogin_Click(object sender, EventArgs e)
        {
            dlgLogin dlg = new dlgLogin();
            dlg.Show();
            
        }

        private void cpnManApartment_StateChanged()
        {
            if (cpnManApartment.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnViPham.PanelState = PanelStateOptions.Collapsed;
                this.cpnManservice.PanelState = PanelStateOptions.Collapsed;
                this.cpnNhanVien.PanelState = PanelStateOptions.Collapsed;
                this.cpnManPeople.PanelState = PanelStateOptions.Collapsed;
                this.cpnLogin.PanelState = PanelStateOptions.Collapsed;
            }
        }

        private void cpnManservice_StateChanged()
        {
            if (cpnManservice.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnManApartment.PanelState = PanelStateOptions.Collapsed;
                this.cpnManPeople.PanelState = PanelStateOptions.Collapsed;
                this.cpnNhanVien.PanelState = PanelStateOptions.Collapsed;
                this.cpnViPham.PanelState = PanelStateOptions.Collapsed;
                this.cpnLogin.PanelState = PanelStateOptions.Collapsed;
            }
        }

        private void cpnManPeople_StateChanged()
        {
            if (cpnManPeople.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnManApartment.PanelState = PanelStateOptions.Collapsed;
                this.cpnManservice.PanelState = PanelStateOptions.Collapsed;
                this.cpnNhanVien.PanelState = PanelStateOptions.Collapsed;
                this.cpnViPham.PanelState = PanelStateOptions.Collapsed;
                this.cpnLogin.PanelState = PanelStateOptions.Collapsed;
            }
        }

        private void cpnNhanVien_StateChanged()
        {
            if (cpnNhanVien.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnManApartment.PanelState = PanelStateOptions.Collapsed;
                this.cpnManservice.PanelState = PanelStateOptions.Collapsed;
                this.cpnManPeople.PanelState = PanelStateOptions.Collapsed;
                this.cpnViPham.PanelState = PanelStateOptions.Collapsed;
                this.cpnLogin.PanelState = PanelStateOptions.Collapsed;
            }
        }

        private void cpnLogin_StateChanged()
        {
            if (cpnLogin.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnManApartment.PanelState = PanelStateOptions.Collapsed;
                this.cpnManservice.PanelState = PanelStateOptions.Collapsed;
                this.cpnManPeople.PanelState = PanelStateOptions.Collapsed;
                this.cpnViPham.PanelState = PanelStateOptions.Collapsed;
                this.cpnNhanVien.PanelState = PanelStateOptions.Collapsed;
            }
        }

        private void cpnViPham_StateChanged()
        {
            if (cpnViPham.PanelState == PanelStateOptions.Expanded)
            {
                this.cpnManApartment.PanelState = PanelStateOptions.Collapsed;
                this.cpnManservice.PanelState = PanelStateOptions.Collapsed;
                this.cpnManPeople.PanelState = PanelStateOptions.Collapsed;
                this.cpnLogin.PanelState = PanelStateOptions.Collapsed;
                this.cpnNhanVien.PanelState = PanelStateOptions.Collapsed;
            }



        }

        private void btLogout_Click(object sender, EventArgs e)
        {

        }

        private void btExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btfind_Click(object sender, EventArgs e)
        {
            try
            {
               
                dgvMain.DataSource = cpnManPeople;
               
            }
            catch (NoNullAllowedException)
            {
                MessageBox.Show("You are not allowed to do that", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                this.Close();
            }
        }

       
        }

    }
    

     
        



      

    
